package com.rmt.www.serviceImpl;

import java.util.List;

import com.rmt.www.constant.ArtifactType;
import com.rmt.www.dao.DesignArtifactDao;
import com.rmt.www.dao.DesignArtifactRequestDao;
import com.rmt.www.dao.FeatureArtifactDao;
import com.rmt.www.dao.FeatureArtifactRequestDao;
import com.rmt.www.dao.ImplementationArtifactDao;
import com.rmt.www.dao.ImplementationArtifactRequestDao;
import com.rmt.www.dao.RequirementArtifactDao;
import com.rmt.www.dao.RequirementArtifactRequestDao;
import com.rmt.www.dao.TestArtifactDao;
import com.rmt.www.dao.TestArtifactRequestDao;
import com.rmt.www.dao.TraceabilityDaoV2;
import com.rmt.www.dao.UserDao;
import com.rmt.www.service.AdminManageDetailService;
import com.rmt.www.vo.DesignArtifactRequest;
import com.rmt.www.vo.FeatureArtifact;
import com.rmt.www.vo.FeatureArtifactRequest;
import com.rmt.www.vo.ImplementationArtifact;
import com.rmt.www.vo.DesignArtifact;
import com.rmt.www.vo.ImplementationArtifactRequest;
import com.rmt.www.vo.RequirementArtifact;
import com.rmt.www.vo.RequirementArtifactRequest;
import com.rmt.www.vo.TestArtifact;
import com.rmt.www.vo.TestArtifactRequest;
import com.rmt.www.vo.TraceabilityV2;

public class AdminManageDetailServiceImpl extends ArtifactDetailQueryServiceImpl implements AdminManageDetailService {
	
	private FeatureArtifactDao featureArtifactDao;
	private FeatureArtifactRequestDao featureArtifactRequestDao;
	private RequirementArtifactDao requirementArtifactDao;
	private RequirementArtifactRequestDao requirementArtifactRequestDao;
	private DesignArtifactRequestDao designArtifactRequestDao;
	private DesignArtifactDao designArtifactDao;
	private ImplementationArtifactDao implementationArtifactDao;
	private ImplementationArtifactRequestDao implementationArtifactRequestDao;
	private TestArtifactDao testArtifactDao;
	private TestArtifactRequestDao testArtifactRequestDao;
 	public UserDao userDao;
 	private TraceabilityDaoV2 traceabilityDaoV2;
 	
 	public TraceabilityDaoV2 getTraceabilityDaoV2() {
		return traceabilityDaoV2;
	}
	public void setTraceabilityDaoV2(TraceabilityDaoV2 traceabilityDaoV2) {
		this.traceabilityDaoV2 = traceabilityDaoV2;
	}
	public DesignArtifact getDesignArtifact(int id) {
 		DesignArtifact a = designArtifactDao.getDesignArtifactById(id);
 		a.set_authorname(userDao.getUser(a.getCreaterid()).getName());
 		int updaterid=a.getUpdaterid();
		if (updaterid != 0)
			a.set_updatername(userDao.getUser(updaterid).getName());
 		return a;
	}
	public FeatureArtifact getFeatureArtifact(int id) {
		FeatureArtifact a = featureArtifactDao.getFeatureArtifactById(id);
		a.set_authorname(userDao.getUser(a.getAuthorId()).getName());
		int updaterid=a.getUpdateUserId();
		if (updaterid != 0)
			a.set_updatername(userDao.getUser(updaterid).getName());
 		return a;
	}
	public ImplementationArtifact getImplementationArtifact(int id) {
		ImplementationArtifact a = implementationArtifactDao.getImplementationArtifactById(id);
		a.set_authorname(userDao.getUser(a.getCreaterid()).getName());
		int updaterid=a.getUpdaterid();
		if (updaterid != 0)
			a.set_updatername(userDao.getUser(updaterid).getName());
 		return a;
	}
	public RequirementArtifact getRequirementArtifact(int id) {
		RequirementArtifact a = requirementArtifactDao.getRequirementArtifactById(id);
		a.set_authorname(userDao.getUser(a.getAuthorId()).getName());
		int updaterid=a.getUpdateUserId();
		if (updaterid != 0)
			a.set_updatername(userDao.getUser(updaterid).getName());
 		return a;
	}
	public TestArtifact getTestArtifact(int id) {
		TestArtifact a = testArtifactDao.getTestArtifactById(id);
		a.set_authorname(userDao.getUser(a.getCreaterid()).getName());
		int updaterid=a.getUpdaterid();
		if (updaterid != 0)
			a.set_updatername(userDao.getUser(updaterid).getName());
 		return a;
	}
 	
	public FeatureArtifactDao getFeatureArtifactDao() {
		return featureArtifactDao;
	}
	public void setFeatureArtifactDao(FeatureArtifactDao featureArtifactDao) {
		this.featureArtifactDao = featureArtifactDao;
	}
	public RequirementArtifactDao getRequirementArtifactDao() {
		return requirementArtifactDao;
	}
	public void setRequirementArtifactDao(
			RequirementArtifactDao requirementArtifactDao) {
		this.requirementArtifactDao = requirementArtifactDao;
	}
	public DesignArtifactDao getDesignArtifactDao() {
		return designArtifactDao;
	}
	public void setDesignArtifactDao(DesignArtifactDao designArtifactDao) {
		this.designArtifactDao = designArtifactDao;
	}
	public ImplementationArtifactDao getImplementationArtifactDao() {
		return implementationArtifactDao;
	}
	public void setImplementationArtifactDao(
			ImplementationArtifactDao implementationArtifactDao) {
		this.implementationArtifactDao = implementationArtifactDao;
	}
	public TestArtifactDao getTestArtifactDao() {
		return testArtifactDao;
	}
	public void setTestArtifactDao(TestArtifactDao testArtifactDao) {
		this.testArtifactDao = testArtifactDao;
	}
	public UserDao getUserDao() {
		return userDao;
	}
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	public DesignArtifactRequest getDesignArtifactRequest(int id) {
		DesignArtifactRequest request = designArtifactRequestDao.getDesignArtifactRequestById(id);
		request.set_authorname(userDao.getUser(request.getCreaterid()).getName());
		if (request.getUpdaterid() != 0)
			request.set_updatername(userDao.getUser(request.getUpdaterid()).getName());
		return request;
	}
	public FeatureArtifactRequest getFeatureArtifactRequest(int id) {
		FeatureArtifactRequest request = featureArtifactRequestDao.getFeatureArtifactRequestById(id);
		request.set_authorname(userDao.getUser(request.getAuthorId()).getName());
		if (request.getUpdateUserId() != 0)
			request.set_updatername(userDao.getUser(request.getUpdateUserId()).getName());
		return request;
	}
	public ImplementationArtifactRequest getImplementationArtifactRequest(int id) {
		ImplementationArtifactRequest request = implementationArtifactRequestDao.getImplementationArtifactRequestById(id);
		request.set_authorname(userDao.getUser(request.getCreaterid()).getName());
		if (request.getUpdaterid() != 0)
			request.set_updatername(userDao.getUser(request.getUpdaterid()).getName());
		return request;
	}
	public RequirementArtifactRequest getRequirementArtifactRequest(int id) {
		RequirementArtifactRequest request = requirementArtifactRequestDao.getRequirementArtifactRequestById(id);
		request.set_authorname(userDao.getUser(request.getAuthorId()).getName());
		if (request.getUpdateUserId() != 0)
			request.set_updatername(userDao.getUser(request.getUpdateUserId()).getName());
		return request;
	}
	public TestArtifactRequest getTestArtifactRequest(int id) {
		TestArtifactRequest request = testArtifactRequestDao.getTestArtifactRequestByRId(id);
		request.set_authorname(userDao.getUser(request.getCreaterid()).getName());
		if (request.getUpdaterid() != 0)
			request.set_updatername(userDao.getUser(request.getUpdaterid()).getName());
		return request;
	}
	public List<TraceabilityV2> getTraceabilityV2ByTo(String totable, int toid) {
		return traceabilityDaoV2.getTraceabilitiesByToId(totable, toid);
	}
	public FeatureArtifactRequestDao getFeatureArtifactRequestDao() {
		return featureArtifactRequestDao;
	}
	public void setFeatureArtifactRequestDao(
			FeatureArtifactRequestDao featureArtifactRequestDao) {
		this.featureArtifactRequestDao = featureArtifactRequestDao;
	}
	public RequirementArtifactRequestDao getRequirementArtifactRequestDao() {
		return requirementArtifactRequestDao;
	}
	public void setRequirementArtifactRequestDao(
			RequirementArtifactRequestDao requirementArtifactRequestDao) {
		this.requirementArtifactRequestDao = requirementArtifactRequestDao;
	}
	public DesignArtifactRequestDao getDesignArtifactRequestDao() {
		return designArtifactRequestDao;
	}
	public void setDesignArtifactRequestDao(
			DesignArtifactRequestDao designArtifactRequestDao) {
		this.designArtifactRequestDao = designArtifactRequestDao;
	}
	public ImplementationArtifactRequestDao getImplementationArtifactRequestDao() {
		return implementationArtifactRequestDao;
	}
	public void setImplementationArtifactRequestDao(
			ImplementationArtifactRequestDao implementationArtifactRequestDao) {
		this.implementationArtifactRequestDao = implementationArtifactRequestDao;
	}
	public TestArtifactRequestDao getTestArtifactRequestDao() {
		return testArtifactRequestDao;
	}
	public void setTestArtifactRequestDao(
			TestArtifactRequestDao testArtifactRequestDao) {
		this.testArtifactRequestDao = testArtifactRequestDao;
	}
	public List<TraceabilityV2> getTraceabilityV2ByFrom(String fromtable, int fromid) {
		return traceabilityDaoV2.getTraceabilitiesByFromId(fromtable, fromid);
	}
	

}
